<script setup lang="ts">
import { storeToRefs } from 'pinia';
import useStore from '../store';

const { todos } = useStore();
const { Todos_List, checkAll } = storeToRefs(todos);
</script>

<template>
  <section class="main">
    <input
      id="toggle-all"
      class="toggle-all"
      type="checkbox"
      :checked="checkAll"
      @click="todos.handlecheckAll(!checkAll)"
    />
    <label for="toggle-all">Mark all as complete</label>
    <ul class="todo-list">
      <li
        :class="item.done ? 'completed' : ''"
        v-for="item in Todos_List"
        :key="item.id"
      >
        <div class="view">
          <input
            class="toggle"
            type="checkbox"
            :checked="item.done"
            @click="todos.handlecheck(item.id)"
          />
          <label>{{ item.name }}</label>
          <button class="destroy" @click="todos.handleDel(item.id)"></button>
        </div>
        <input class="edit" value="Create a TodoMVC template" />
      </li>
    </ul>
  </section>
</template>

<style lang="less" scoped></style>
